/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            repairDetailResourceInfo: {
                resources: [],
                repairId: '',
                staffNameLike: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('repairDetailResource', 'switch', function (_data) {
                $that.repairDetailResourceInfo.repairId = _data.repairId;
                $that._loadRepairDetailResourceData(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('repairDetailResource', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadRepairDetailResourceData(_currentPage, DEFAULT_ROWS);
                });
            vc.on('repairDetailResource', 'notify', function (_data) {
                $that._loadRepairDetailResourceData(DEFAULT_PAGE, DEFAULT_ROWS);
            })
        },
        methods: {
            _loadRepairDetailResourceData: function (_page, _row) {
                var param = {
                    params: {
                        page: 1,
                        row: 100,
                        communityId: vc.getCurrentCommunity().communityId,
                        repairId: $that.repairDetailResourceInfo.repairId
                    }
                };
                //发送get请求
                vc.http.apiGet('/resourceStore.listResourceStoreUseRecords',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        let _resource = _json.data;
                        $that.repairDetailResourceInfo.resources = _resource;
                        $that.repairDetailResourceInfo.resources.forEach((item) => {
                            if (item.resId == '666666') {
                                item.rstName = item.specName = '自定义';
                            }
                        })
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _queryRepairDetailResource: function () {
                $that._loadRepairDetailResourceData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _resetRepairDetailResource: function () {
                $that._loadRepairDetailResourceData(DEFAULT_PAGE, DEFAULT_ROWS);
            }
        }
    });
})(window.vc);